home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 412_01 / src / aosear / taodepth.cpp < prev   
Encoding:
C/C++ Source or Header  |  1993-12-28  |  851 b   |  45 lines

  1. #include "tree.h"
  2.  
  3. /*            AODEPTH_TREE_
  4.  
  5.     The constructor passes the start node and number of operators on
  6.     to AOSEARCH_
  7.  
  8. */
  9.  
  10. AODEPTH_TREE_::AODEPTH_TREE_(AONODE_ *start, int op)
  11.     :AOSEARCH_(start, op)
  12. {
  13. }
  14.  
  15.  
  16.  
  17. /*            ADD
  18.  
  19.     This routine adds nodes to the search tree (it adds them to
  20.     the HEAD of open). Nodes of type AND get special treatment: they
  21.     are not meant to be stored on open, but each of its successors is.
  22.  
  23. */
  24.  
  25. void AODEPTH_TREE_::add(AONODE_ *succ)
  26. {
  27.     AONODE_
  28.     *node;
  29.     int
  30.     i;
  31.  
  32.     if (succ->gettype() == AND)
  33.     {
  34.         i = ((ANDNODE_ *)succ)->getn_nodes() - 1;
  35.     for ( ;i >= 0; i--)        /* put all successor nodes on open */
  36.     {
  37.         node = ((ANDNODE_ *)succ)->getsucc(i);
  38.         node->setparent(succ);
  39.         open.addtohead(*node);
  40.     }
  41.     }
  42.     else
  43.     open.addtohead(*succ);
  44. }
  45.